﻿namespace Idlesoft.ShellAnywhereParser

open System
open FParsec
open Idlesoft.ShellAnywhereLanguage

type Verbeme = ILexeme<IVerb>
type Targeme = ILexeme<ITarget>
type Parmeme = ILexeme<IParam>

type UserState = { Verb : IVerb option; Target : ITarget option }
    with static member Default = {Verb = None;Target=None}

type Parser<'t> = Parser<'t, UserState>

type Ident = string

type Matched =
    | Verb of IVerb
    | Target of ITarget
    | ParamList of IParam list

type Unmatched =
    | Verbeme of ILexeme<IVerb>
    | Targeme of ILexeme<ITarget>
    | Parmeme of ILexeme<IParam>

type Stmt =
    //matched
    | VerbTargetParamList of    Matched * Matched * Matched    
    | VerbTarget of             Matched * Matched                   
    | TargetParamList of        Matched * Matched
    | Verb of                   Matched                
    | Target of                 Matched
    | ParamList of              Matched

    //unmatched
    | VerbTargetParmeme of      Matched * Matched * Unmatched       
    | VerbTargeme of            Matched * Unmatched                 
    | TargetParmeme of          Matched * Unmatched  
    | Verbeme of                Unmatched
    | Targeme of                Unmatched
    | Parmeme of                Unmatched  

type Expr = 
    | Var of Ident
    | Int of int
    | Float of float32
    | Double of double
    | String of string
    | Oper of Expr * Expr list

